﻿using System.Collections;
using System.Collections.Generic;
using System;
public interface IHander
{
    void Register(Dictionary<Protocal, Action<ByteBuffer>> handlers);
}
/// <summary>
/// 消息的分发 调度
/// </summary>
public class HanderCenter
{
    protected Dictionary<Protocal, Action<ByteBuffer>> handlers = new Dictionary<Protocal, Action<ByteBuffer>>();

    AccountHandle accountHandler=new AccountHandle();
    BattleHandle battleHandle=new BattleHandle();
    public HanderCenter()
    {
        accountHandler.Register(handlers);
        battleHandle.Register(handlers);
    }
    public void ReceiveMessage(ByteBuffer buffer)
    {
        Protocal type = (Protocal)buffer.ReadByte();

        handlers[type](buffer);
    }
}
